import { Menu } from 'antd'
import { Link, useLocation } from 'react-router-dom'
import routes from '../../router'

const MyMenu = (props) => {
  const { pathname } = useLocation()
  return (
    <Menu
      theme="dark"
      mode="inline"
      selectedKeys={[pathname]}
      defaultSelectedKeys={'/'}
    >
      {routes
        .filter((item) => !item.isHidden)
        .map((item) => (
          // subMenu 单独开一个主菜单目录
          // <SubMenu>
          <Menu.Item key={item.path}>
            <Link to={item.path}>{item.name}</Link>
          </Menu.Item>
          // </SubMenu>
        ))}
    </Menu>
  )
}
export default MyMenu
